package com.sgcc.sx.pmos.common.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.IntentUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.core.CenterPopupView;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.common.utils.DateUtils;
import com.sgcc.sx.pmos.common.utils.DialogUtil;
import com.sgcc.sx.pmos.e_sx_mall.bean.StoreHomeBean;
import com.sgcc.sx.pmos.e_sx_personalcenter.activity.FeedBackActivity;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class StoreDetailsPopView extends BottomPopupView {
    private TextView tv_title,tv_xypj, tv_clsj, tv_dlqy, tv_lxdh, tv_title_1, tv_title_2, tv_title_3, tv_content_1, tv_content_2, tv_content_3;

    private ImageView im_close;
    StoreHomeBean.RowsBean bean;
    Context context;

    public StoreDetailsPopView(Context context, StoreHomeBean.RowsBean bean) {
        super(context);
        this.bean = bean;
        this.context = context;
    }


    @Override
    protected int getImplLayoutId() {
        return R.layout.store_details_pop;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        tv_title= (TextView) findViewById(R.id.tv_title);
        tv_xypj = (TextView) findViewById(R.id.tv_xypj);
        tv_clsj = (TextView) findViewById(R.id.tv_clsj);
        tv_dlqy = (TextView) findViewById(R.id.tv_dlqy);
        tv_lxdh = (TextView) findViewById(R.id.tv_lxdh);
        tv_title_1 = (TextView) findViewById(R.id.tv_title_1);
        tv_title_2 = (TextView) findViewById(R.id.tv_title_2);
        tv_title_3 = (TextView) findViewById(R.id.tv_title_3);
        tv_content_1 = (TextView) findViewById(R.id.tv_content_1);
        tv_content_2 = (TextView) findViewById(R.id.tv_content_2);
        tv_content_3 = (TextView) findViewById(R.id.tv_content_3);

        im_close = findViewById(R.id.im_close);
        im_close.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });

        tv_title.setText(bean.getMembersSdName());


        tv_xypj.setText(TextUtils.isEmpty(bean.getCreditRating()) ? "——" : bean.getCreditRating());

        if(TextUtils.isEmpty(bean.getMarketDate())){
            tv_clsj.setText("——");
        }else{
//            DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
            if(bean.getMarketDate().length()>10){
                tv_clsj.setText(bean.getMarketDate().substring(0,10));
            }else{
                tv_clsj.setText(bean.getMarketDate().substring(0,bean.getMarketDate().length()));
            }

        }

        tv_dlqy.setText(TextUtils.isEmpty(bean.getGeogrregionId()) ? "——" : bean.getGeogrregionId());

        tv_lxdh.setText(TextUtils.isEmpty(bean.getTel()) ? "——" : bean.getTel() + "");
        tv_title_1.setText(bean.getShopsTitile1());
        tv_title_2.setText(bean.getShopsTitile2());
        tv_title_3.setText(bean.getShopsTitile3());

        tv_content_1.setText(bean.getShopsContent1());
        tv_content_2.setText(bean.getShopsContent2());
        tv_content_3.setText(bean.getShopsContent3());
        tv_lxdh.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.equals("——", tv_lxdh.getText().toString())) {
                    ToastUtils.showShort("联系电话为空");
                } else {
                    DialogUtil.showCallPhone(context,tv_lxdh.getText().toString());
                }
            }
        });
    }

    @Override
    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
    }

}